<?php

header("Content-Type:text/html;charset=utf-8");//设置页面内容是html,编码格式是utf-8

$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "message";

// 创建连接
$conn = new mysqli($servername, $username, $password,$dbname);

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 
$conn->query("set names 'utf8'");  //设置这个数据库的存储编码为utf8
?>